﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace _8_21_Classwork_Cafe.Models
{
    public class CafeShop
    {
        public string Name { get; set; }
		public int ID;
		public string Image { get; set; }
		public string Info { get; set; }
        public string Address { get; set; }
        public string Phone { get; set; }

		//public List<Review> reviews = new List<Review>();
        public List<ReviewStruct> reviews = new List<ReviewStruct>();
        public int AvgRating()
        {
            int average=0;
            int count = 0;
            foreach (var r in reviews){
                count++;
                average += r.Rating;
            }
            if (count == 0)
            {
                return count;
            }else{
            return (average/count);
            }
        }
		private static int NextCafeID = 0;
		public CafeShop(){}
		public CafeShop(string cafename, string cafeinfo, string image,string address, string phone)
		{
			Image = image;
			Info = cafeinfo;
			Name = cafename;
            Address = address;
            Phone = phone;
			ID = NextCafeID;
			NextCafeID++;
		}
    }
}